#include "config_main.h"
#ifdef DDENN_DUMMY_DATAREFS
/*
 * dummy_datarefs.c
 *
 *  Created on: 06.06.2009
 *      Author: Admin
 */

#include "dummy_datarefs.h"


int DdennDummyDataRefs::DDennDummyInteger[DDENN_DUMMY_INTEGER_COUNT];
float DdennDummyDataRefs::DDennDummyFloat[DDENN_DUMMY_FLOAT_COUNT];
double DdennDummyDataRefs::DDennDummyDouble[DDENN_DUMMY_DOUBLE_COUNT];


void DdennDummyDataRefs::RegisterDdennDummyDataRefs(){
    for (int i=0; i<(DDENN_DUMMY_INTEGER_COUNT); ++i){
     	DDennDummyInteger[i]=0;
    	XPLMRegisterDataAccessor( StPrintI("ddenn/dummy/int%d", i) ,    xplmType_Int, 1,
    	                                   GetDummyDataRef_i,
    	                                   SetDummyDataRef_i,NULL,NULL,NULL, NULL,NULL,NULL,NULL,  NULL,NULL,    NULL,  &(DDennDummyInteger[i]), &(DDennDummyInteger[i]));
    }

    for (int i=0; i<(DDENN_DUMMY_FLOAT_COUNT); ++i){
      	DDennDummyFloat[i]=0;
    	XPLMRegisterDataAccessor( StPrintI("ddenn/dummy/float%d", i) ,    xplmType_Float, 1, NULL,NULL,
    	                                   GetDummyDataRef_f,
    	                                   SetDummyDataRef_f,
    	                                   NULL, NULL,NULL,NULL,NULL,  NULL,NULL,    NULL,  &(DDennDummyFloat[i]), &(DDennDummyFloat[i]));
    }

    for (int i=0; i<(DDENN_DUMMY_DOUBLE_COUNT); ++i){
    	DDennDummyDouble[i]=0;
    	XPLMRegisterDataAccessor( StPrintI("ddenn/dummy/double%d", i) ,    xplmType_Double, 1, NULL,NULL,NULL, NULL,
    	                                   GetDummyDataRef_d,
    	                                   SetDummyDataRef_d,NULL,NULL,NULL,  NULL,NULL,    NULL,  &(DDennDummyDouble[i]), &(DDennDummyDouble[i]));
    }
}

void DdennDummyDataRefs::UnregisterDdennDummyDataRefs(){
	for (int i=0; i<(DDENN_DUMMY_INTEGER_COUNT); ++i){
		XPLMUnregisterDataAccessor( XPLMFindDataRef(StPrintI("ddenn/dummy/int%d", i) ));
	}

	for (int i=0; i<(DDENN_DUMMY_FLOAT_COUNT); ++i){
		XPLMUnregisterDataAccessor( XPLMFindDataRef(StPrintI("ddenn/dummy/float%d", i) ));
	}

	for (int i=0; i<(DDENN_DUMMY_DOUBLE_COUNT); ++i){
		XPLMUnregisterDataAccessor( XPLMFindDataRef(StPrintI("ddenn/dummy/double%d", i) ));
	}
}



void DdennDummyDataRefs::SetDummyDataRef_i(void *               inRefcon,
                 int                  inValue)
{
	int *p = (int*)inRefcon;
	*p = inValue;
}

int DdennDummyDataRefs::GetDummyDataRef_i( void *               inRefcon)
{
	int *p = (int*)inRefcon;
	return *p;
}




void DdennDummyDataRefs::SetDummyDataRef_f(void *               inRefcon,
                 float                  inValue)
{
	float *p = (float*)inRefcon;
	*p = inValue;
}

float DdennDummyDataRefs::GetDummyDataRef_f( void *               inRefcon)
{
	float *p = (float*)inRefcon;
	return *p;
}




void DdennDummyDataRefs::SetDummyDataRef_d(void *               inRefcon,
                 double                  inValue)
{
	double *p = (double*)inRefcon;
	*p = inValue;
}

double DdennDummyDataRefs::GetDummyDataRef_d( void *               inRefcon)
{
	double *p = (double*)inRefcon;
	return *p;
}

/**************************************************************************************/
//
//       end
//
/*************************************************************************************/



#endif
